aboutsummaryrefslogtreecommitdiffstats
path: root/src/app/groups/[groupId]
diff options
context:
space:
mode:
authorSebastien Castiel <sebastien@castiel.me>2023-12-06 12:39:54 -0500
committerSebastien Castiel <sebastien@castiel.me>2023-12-06 12:39:54 -0500
commitc72311d01a827a61d6d3d786416ddb442076d73a (patch)
tree131861ab1df1a0cb09ed52ead5ecde8edad6e997 /src/app/groups/[groupId]
parent6c4ced0f79f801d85da5e4973ae4154f01b04dba (diff)
Better loading behavior
Diffstat (limited to 'src/app/groups/[groupId]')
-rw-r--r--src/app/groups/[groupId]/edit/page.tsx16
-rw-r--r--src/app/groups/[groupId]/expenses/[expenseId]/edit/loading.tsx3
-rw-r--r--src/app/groups/[groupId]/expenses/[expenseId]/edit/page.tsx22
-rw-r--r--src/app/groups/[groupId]/layout.tsx13
-rw-r--r--src/app/groups/[groupId]/loading.tsx3
5 files changed, 15 insertions, 42 deletions
diff --git a/src/app/groups/[groupId]/edit/page.tsx b/src/app/groups/[groupId]/edit/page.tsx
index 23bd865..f902428 100644
--- a/src/app/groups/[groupId]/edit/page.tsx
+++ b/src/app/groups/[groupId]/edit/page.tsx
@@ -1,9 +1,6 @@
import { GroupForm } from '@/components/group-form'
-import { Button } from '@/components/ui/button'
import { getGroup, updateGroup } from '@/lib/api'
import { groupFormSchema } from '@/lib/schemas'
-import { ChevronLeft } from 'lucide-react'
-import Link from 'next/link'
import { notFound, redirect } from 'next/navigation'
export default async function EditGroupPage({
@@ -21,16 +18,5 @@ export default async function EditGroupPage({
redirect(`/groups/${group.id}`)
}
- return (
- <main>
- <div className="mb-4">
- <Button variant="ghost" asChild>
- <Link href={`/groups/${groupId}`}>
- <ChevronLeft className="w-4 h-4 mr-2" /> Back to group
- </Link>
- </Button>
- </div>
- <GroupForm group={group} onSubmit={updateGroupAction} />
- </main>
- )
+ return <GroupForm group={group} onSubmit={updateGroupAction} />
}
diff --git a/src/app/groups/[groupId]/expenses/[expenseId]/edit/loading.tsx b/src/app/groups/[groupId]/expenses/[expenseId]/edit/loading.tsx
deleted file mode 100644
index 2b6ca56..0000000
--- a/src/app/groups/[groupId]/expenses/[expenseId]/edit/loading.tsx
+++ /dev/null
@@ -1,3 +0,0 @@
-export default function Loading() {
- return <p>Loading…</p>
-}
diff --git a/src/app/groups/[groupId]/expenses/[expenseId]/edit/page.tsx b/src/app/groups/[groupId]/expenses/[expenseId]/edit/page.tsx
index f22ac08..934d346 100644
--- a/src/app/groups/[groupId]/expenses/[expenseId]/edit/page.tsx
+++ b/src/app/groups/[groupId]/expenses/[expenseId]/edit/page.tsx
@@ -1,9 +1,6 @@
import { ExpenseForm } from '@/components/expense-form'
-import { Button } from '@/components/ui/button'
import { getExpense, getGroup, updateExpense } from '@/lib/api'
import { expenseFormSchema } from '@/lib/schemas'
-import { ChevronLeft } from 'lucide-react'
-import Link from 'next/link'
import { notFound, redirect } from 'next/navigation'
export default async function EditExpensePage({
@@ -24,19 +21,10 @@ export default async function EditExpensePage({
}
return (
- <main>
- <div className="mb-4">
- <Button variant="ghost" asChild>
- <Link href={`/groups/${groupId}`}>
- <ChevronLeft className="w-4 h-4 mr-2" /> Back to group
- </Link>
- </Button>
- </div>
- <ExpenseForm
- group={group}
- expense={expense}
- onSubmit={updateExpenseAction}
- />
- </main>
+ <ExpenseForm
+ group={group}
+ expense={expense}
+ onSubmit={updateExpenseAction}
+ />
)
}
diff --git a/src/app/groups/[groupId]/layout.tsx b/src/app/groups/[groupId]/layout.tsx
index f8030c6..438afea 100644
--- a/src/app/groups/[groupId]/layout.tsx
+++ b/src/app/groups/[groupId]/layout.tsx
@@ -15,13 +15,20 @@ export default async function GroupLayout({
if (!group) notFound()
return (
- <main>
+ <>
<div className="mb-4 flex justify-between">
<Button variant="ghost" asChild>
<Link href="/groups">
<ChevronLeft className="w-4 h-4 mr-2" /> Back to recent groups
</Link>
</Button>
+ </div>
+
+ <div className="flex justify-between items-baseline mb-4">
+ <h1 className="font-bold text-2xl">
+ <Link href={`/groups/${groupId}`}>{group.name}</Link>
+ </h1>
+
<Button variant="secondary" asChild>
<Link href={`/groups/${groupId}/edit`}>
<Edit className="w-4 h-4 mr-2" /> Edit group settings
@@ -29,9 +36,7 @@ export default async function GroupLayout({
</Button>
</div>
- <h1 className="font-bold mb-4">{group.name}</h1>
-
{children}
- </main>
+ </>
)
}
diff --git a/src/app/groups/[groupId]/loading.tsx b/src/app/groups/[groupId]/loading.tsx
deleted file mode 100644
index 2b6ca56..0000000
--- a/src/app/groups/[groupId]/loading.tsx
+++ /dev/null
@@ -1,3 +0,0 @@
-export default function Loading() {
- return <p>Loading…</p>
-}